package com.chinasoft.mall.util;

import java.io.File;
import java.util.List;

import android.content.Context;
import android.os.Environment;
import android.util.DisplayMetrics;

public class SystemSetting {
	public static String IMES = "000000000000000";
	public static String versionId = "0.0.0.0";
	public static List<String> goodsids;
	public static int SCREEN_WIDTH = 480;
	public static int SCREEN_HEIGHT = 800;

	public static final String STOREAGE_NOSDCARD_ADDRESS = "com.chinasoft.mall";

	/**
	 * 初始化存储目录
	 */
	public static boolean initStorageDir() {
		boolean boo = false;
		try {
			String filePath = getDownloadFilePath();
			File file = new File(filePath);
			if (!file.exists()) {
				boo = file.mkdir();
			}
			boo = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return boo;
	}

	/**
	 * 获取下载路径
	 * 
	 * @return
	 */
	public static String getDownloadFilePath() {
		if (isExistSdCard()) {
			return Environment.getExternalStorageDirectory() + "/Mall_Android/";
		} else {
			return "/data/data/" + STOREAGE_NOSDCARD_ADDRESS + "/";
		}
	}

	/**
	 * 是否存在sd卡
	 * 
	 * @return
	 */
	public static final boolean isExistSdCard() {
		if (android.os.Environment.getExternalStorageState().equals(
				android.os.Environment.MEDIA_MOUNTED)) {
			return true;
		} else {
			return false;
		}
	}

	public static void init(Context cx) {
		IMES = SystemUtil.getImei(cx);
		versionId = SystemUtil.getversionId(cx);
		goodsids = LocalDataCommend.getGoodsSelect(cx);
		DisplayMetrics dm = new DisplayMetrics();
		dm = cx.getApplicationContext().getResources().getDisplayMetrics();

		SCREEN_WIDTH = dm.widthPixels;
		SCREEN_HEIGHT = dm.heightPixels;
	}
}
